<!--
 * @copyright 2025 银杏ERP
 * @author 银杏ERP
 * @version 1.0
 * @license http://www.hhyx.xyz
 * @developer Lhf
-->

<template>
    <div class="statistics-panel">
        <el-row :gutter="15">
            <el-col v-for="(item, index) in statisticsData" :key="index" :xs="12" :sm="8" :md="4">
                <div class="stat-card" :class="item.type">
                    <div class="stat-icon">
                        <Icon :name="item.icon" />
                    </div>
                    <div class="stat-content">
                        <div class="stat-title">{{ t(item.title) }}</div>
                        <div class="stat-value">{{ item.value }}</div>
                        <div class="stat-trend" :class="item.trend.type">
                            <Icon :name="getTrendIcon(item.trend.type)" class="trend-icon" />
                            <span>{{ item.trend.value }}</span>
                        </div>
                    </div>
                </div>
            </el-col>
        </el-row>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import Icon from '/@/components/icon/index.vue'

const { t } = useI18n()

// 统计数据
const statisticsData = ref([
    {
        icon: 'fa fa-sign-in',
        title: '今日入库',
        value: '89',
        type: 'inbound',
        trend: {
            type: 'up',
            value: '12.3%'
        }
    },
    {
        icon: 'fa fa-sign-out',
        title: '今日出库',
        value: '56',
        type: 'outbound',
        trend: {
            type: 'down',
            value: '4.6%'
        }
    },
    {
        icon: 'fa fa-cubes',
        title: '总库存量',
        value: '25,673',
        type: 'inventory',
        trend: {
            type: 'up',
            value: '8.2%'
        }
    },
    {
        icon: 'fa fa-exclamation-triangle',
        title: '库存预警',
        value: '18',
        type: 'warning',
        trend: {
            type: 'up',
            value: '3.1%'
        }
    },
    {
        icon: 'fa fa-tags',
        title: '商品种类',
        value: '2,158',
        type: 'products',
        trend: {
            type: 'stable',
            value: '0.5%'
        }
    },
    {
        icon: 'fa fa-calendar-times-o',
        title: '近效期批次',
        value: '8',
        type: 'expiring',
        trend: {
            type: 'down',
            value: '2.8%'
        }
    }
])

// 获取趋势图标
const getTrendIcon = (type: string): string => {
    if (type === 'up') return 'fa fa-long-arrow-up'
    if (type === 'down') return 'fa fa-long-arrow-down'
    return 'fa fa-minus'
}
</script>

<style scoped lang="scss">
.statistics-panel {
    margin-bottom: 20px;
    
    .stat-card {
        background-color: #fff;
        border-radius: 8px;
        padding: 15px;
        display: flex;
        align-items: center;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
        margin-bottom: 15px;
        transition: all 0.3s;
        
        &:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
        
        &.inbound {
            .stat-icon {
                background-color: rgba(64, 158, 255, 0.1);
                color: #409EFF;
            }
            
            .stat-value {
                color: #409EFF;
            }
        }
        
        &.outbound {
            .stat-icon {
                background-color: rgba(103, 194, 58, 0.1);
                color: #67C23A;
            }
            
            .stat-value {
                color: #67C23A;
            }
        }
        
        &.inventory {
            .stat-icon {
                background-color: rgba(144, 147, 153, 0.1);
                color: #909399;
            }
            
            .stat-value {
                color: #606266;
            }
        }
        
        &.warning {
            .stat-icon {
                background-color: rgba(230, 162, 60, 0.1);
                color: #E6A23C;
            }
            
            .stat-value {
                color: #E6A23C;
            }
        }
        
        &.products {
            .stat-icon {
                background-color: rgba(144, 19, 254, 0.1);
                color: #9013FE;
            }
            
            .stat-value {
                color: #9013FE;
            }
        }
        
        &.expiring {
            .stat-icon {
                background-color: rgba(245, 108, 108, 0.1);
                color: #F56C6C;
            }
            
            .stat-value {
                color: #F56C6C;
            }
        }
        
        .stat-icon {
            width: 50px;
            height: 50px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            margin-right: 15px;
        }
        
        .stat-content {
            flex: 1;
            
            .stat-title {
                font-size: 13px;
                color: #909399;
                margin-bottom: 5px;
            }
            
            .stat-value {
                font-size: 24px;
                font-weight: bold;
                margin-bottom: 5px;
            }
            
            .stat-trend {
                font-size: 12px;
                display: flex;
                align-items: center;
                
                &.up {
                    color: #67C23A;
                }
                
                &.down {
                    color: #F56C6C;
                }
                
                &.stable {
                    color: #909399;
                }
                
                .trend-icon {
                    margin-right: 5px;
                }
            }
        }
    }
}

@media screen and (max-width: 768px) {
    .statistics-panel {
        .stat-card {
            padding: 10px;
            
            .stat-icon {
                width: 40px;
                height: 40px;
                font-size: 16px;
                margin-right: 10px;
            }
            
            .stat-content {
                .stat-value {
                    font-size: 18px;
                }
            }
        }
    }
}
</style> 